﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using motelmanagement.common;
using System.Data;
using System.Data.OleDb;
namespace motelmanagement.dao
{
    class RoomStatusDAO
    {
        SqlUtil sqlUtil = new SqlUtil();
        OleDbCommand cmd = null;
        private string strSql = null;

        public DataTable getAllRoomStatus() {
            cmd = new OleDbCommand("Select * from Rooms_status");
            sqlUtil.Load(cmd);
            return sqlUtil;
        }
        public DataTable getRoomStatus(int id)
        {
            cmd = new OleDbCommand("Select * from Rooms_status Where rooms_status_id = @id");
            cmd.Parameters.Add("id",SqlDbType.Int).Value=id;
            sqlUtil.Load(cmd);
            return sqlUtil;
        }
        public void insertRoomStatus(string name) {
            cmd = new OleDbCommand("Insert Into Rooms_status(room_status_name) Values(@name)");
            cmd.Parameters.Add("name", SqlDbType.NText).Value = name;
            sqlUtil.ExecuteNoneQuery(cmd);
        }
        public void updateRoomStatus(int id,string name)
        {
            cmd = new OleDbCommand("Update Rooms_status Set room_status_name = @name Where room_status_id = @id)");
            cmd.Parameters.Add("name", SqlDbType.NText).Value = name;
            cmd.Parameters.Add("id", SqlDbType.Int).Value = id;
            sqlUtil.ExecuteNoneQuery(cmd);
        }
        public void deleteRoomStatus(int id)
        {
            cmd = new OleDbCommand("Delete From Rooms_status Where room_status_id = @id)");
            cmd.Parameters.Add("id", SqlDbType.Int).Value = id;
            sqlUtil.ExecuteNoneQuery(cmd);
        }

    }
}
